Skip to content

feat(warm-pool): a worker with no targets keeps the kinds it has leased ready - #792

Merged
V3RON merged 48 commits into
task/774from
task/776
Oct 21, 2026
Merged

V3RON merged 48 commits into
task/774from
task/776

Conversation

@V3RON

@V3RON V3RON commented Oct 20, 2026 •

Copy link
Copy Markdown
Contributor

Closes #776

Status

Implement: done, audited Review: passed (rounds 2 + 2 fix-checks, 0 open) Hardware: pass (8b3b067, 4/4) Gate: waiting for the stack

Done when

  • pnpm test:changed passes. (audit run, 109 files, 5179 tests)
  • pnpm test:e2e e2e/warm-pool-learned.test.ts e2e/warm-pool-reserve.test.ts passes. (audit and fix runs)
  • rg -n "recently-released" src docs --glob '!docs/internal/adr/**' finds nothing. (audit)
  • Needs real devices: scripts/slow-e2e.sh e2e/slow-warm-pool.test.ts passes its new "with no target" case. (slow lane at 8b3b067, whole file 4/4)

Assumptions

  • Assumption: a learned kind whose platform's catalog read failed, timed out or has not answered yet is kept and planned for nothing that pass, as ADR 0038 §4 says; Tests: a converger test where a pending or failed read plans no boot for the kind and a later successful read boots it (decided in delivery, pending the maintainer; test: converger.test.ts "keeps a learned kind and plans nothing for it while its platform's catalog read is pending, failed or timed out…").

  • Assumption: existing tests that a learned kind now changes (create-leasing.test.ts RAM budget after restart, main.test.ts quarantine display, warm-targets.test.ts idle shutdown of a leased non-targeted kind) — adapted to the new behaviour (the kind is kept and refilled), not to a different one; the pool is switched off only where a test is about something else.

  • Assumption: a kind's device under an operation claim (a reclaim that has not given its claim up) counts as had — so the pass device.reclaimed triggers does not create a second device while the first is still being finished.

  • Assumption: the pool reads the catalog through the DriverCatalog createCore already builds from its drivers — no new catalog option on createCore and none for its callers; the smallest change with the same behaviour.

  • Assumption: a learned kind is displaced only by a newer learned kind, on the same platform, and only when the newer kind is short for a running slot (not when a handoff is in flight).

  • Assumption: the "a new 3 GiB device fits" request in the create-leasing restart test is replaced by the pool's own slim device taking the freed 2 GiB (makeReady +1, used 4 GiB): the pool refills the freed RAM before a request can use it.

  • Assumption: warm-pool-reserve re-derived: the pool's boot of the released device counts among the three concurrent boots, so four makeReady calls, not five, are seen while it runs.

  • Assumption: capacity-cleanup-nuke "demotes an idle device" now expects a leased kind's idle device kept (as warm-targets already does) and the dry-run preview not to propose it (no device here is one a rule acts on, so that a dry run executes nothing stays the reaper unit test's); attention.spec, ram-budget-by-mode run with the pool off (they are about something else); doctor-drift allows the pool's refill creation.

Review

Spec review: 1 blocking, 1 fixed, 0 notes. Code review: 6 blocking, 6 fixed, 0 notes. Claims review: 3 blocking, 3 fixed, 1 notes.
Rounds: 2. Tokens: 7.0M.
Runs: 23. Cost USD: 30.2909. Agent seconds: 42153.
Assessment: complete

Written by an agent.

V3RON added 30 commits October 20, 2026 22:16
… kinds newest first, and counts a learned kind's leased and reclaiming devices as had (#776)
…r-leased-idle while the kind wants it, and proposes one beyond its count after idle.shutdownAfterMs (#776)
…idle ready device for a newer kind short for a running slot (#776)
…count, and WarmPool.targeted() includes them before the first pass and after a restart (#776)
…lease.expired, skips a physical device, learns nothing with warmPool.enabled false (#776)
…holds, and the first pass boots the recorded kinds (#776)
…nd and forgets kinds the catalog no longer lists (#776)
…ly, and target-missed judges a merged entry by its configured count (#776)
…ut learned kinds, and start() survives a closeOpen throw (#776)
@V3RON

V3RON commented Oct 21, 2026

Copy link
Copy Markdown
Contributor Author

Handoff

Audit stopped at the session budget limit (10 h), before it finished.

Done:

  • Read the spec and the PR body.
  • Read src/core/warm-pool/learned.ts. No defect found: peak overlap, the 32-per-platform cap and the 24 h prune match the spec.
  • rg -n "recently-released" src docs --glob '!docs/internal/adr/**' finds nothing.
  • .agents/scripts/stale-refs.sh 3aca357d 851801f4 printed nothing.

Not done:

  • pnpm test:changed was started and moved to the background. Its result was not read.
  • pnpm test:e2e e2e/warm-pool-learned.test.ts e2e/warm-pool-reserve.test.ts was not run.
  • The policy, converger, retry, reaper and nuke diffs were not reviewed.
  • No per-test probes were run (0 of the added or changed tests).
  • The docs sweep for removed facts was not done.

The next audit starts from head 851801f with base 3aca357.

…catalog check, failure and displacement tests; docs: the tick row and nuke step (#776)
@V3RON

V3RON commented Oct 21, 2026

Copy link
Copy Markdown
Contributor Author

Decision taken

Question (review R4): while a platform's catalog read has failed, timed out or not answered yet, does the pool keep booting that platform's learned kinds from its record?

  • Boots go on (what the issue's failure table said, and the code did): a kind whose model or runtime is gone costs one failed boot per retry until the read succeeds.
  • Plan nothing that pass (ADR 0038 §4, accepted): the kind is kept, but no device of it is booted or created until a read answers. A user sees learned devices come back a pass later after a restart or a slow simctl/avdmanager.

Taken: plan nothing that pass. The accepted ADR binds, and it never boots from a record nobody has checked. Issue body amended; an Assumption line names the test.

Reverting: restore the table row in #776 and drop the planning guard in src/core/warm-pool/catalog-check.ts with its test; one fix run.

Written by an agent.

V3RON added 6 commits October 21, 2026 09:02
…ared target's device, log the shutdown reason, plan nothing for a kind with no catalog answer; tests restored for the reset stop (#776)
…ad test runs its pass, docs name learned kinds beside targets (#776)
…nd has a ready one: the pool's keep rule for recently released devices is gone (#776)
@V3RON

V3RON commented Oct 21, 2026

Copy link
Copy Markdown
Contributor Author

Review ledger

Runs: 23. Cost USD: 30.2909. Agent seconds: 42153.
Tokens input 1584, output 474305, cache read 73261182, cache write 6188327.
- build implementer: claude-sonnet-5-5 56 s $0.132
- build implementer: claude-sonnet-5-5 6762 s $5.8571
- build implementer: claude-sonnet-5-5 8078 s $5.6728
- build implementer: claude-sonnet-5-5 13414 s $5.4924
- audit implementer: claude-sonnet-5-5 2908 s $0.4504
- audit implementer: claude-sonnet-5-5 1489 s $1.2881
- review 1 reviewer: claude-sonnet-5-5 833 s $0.2947
- review 1 spec: claude-sonnet-5-5 98 s $0.5856
- review 1 code both: claude-opus-5-5 714 s $3.5208
- review 1 claims: claude-sonnet-5-5 101 s $0.3245
- fix 1 implementer: claude-sonnet-5-5 1162 s $1.3421
- review 2 reviewer: claude-sonnet-5-5 528 s $0.3429
- review 2 spec: claude-sonnet-5-5 62 s $0.3254
- review 2 code both: claude-opus-5-5 290 s $1.3676
- review 2 claims: claude-sonnet-5-5 399 s $1.1335
- fix 2 implementer: claude-sonnet-5-5 638 s $0.2532
- review fix-check reviewer: claude-sonnet-5-5 391 s $0.2152
- review fix-check code both: claude-opus-5-5 322 s $0.6066
- review fix-check claims: claude-sonnet-5-5 63 s $0.1408
- hardware hardware-verifier: claude-sonnet-5-5 1393 s $0.1618
- hardware-fix implementer: claude-sonnet-5-5 1220 s $0.5005
- hardware hardware-verifier: claude-sonnet-5-5 1175 s $0.1529
- review fix-check reviewer: claude-sonnet-5-5 57 s $0.13
Finding outcomes: {"fixed":11}. Classes: {"safety 6: reason not logged":1,"spared target devices never displaced":1,"spec versus ADR 0038 section 4":1,"spec vs rule: ADR 0038 section 5 first pass":1,"spec: displace only for running slot":1,"stale claim: no target keeps it":1,"stale claim: only targets keep fresh warm":1,"test title claims failed read, never exercised":1,"test title claims physical device skip, none in fixture":1,"testing 1, 10":1,"testing: deleted test leaves behaviour unproven":1}.
{
 "findings": [
  {
   "id": "R1",
   "role": "code",
   "class": "spec: displace only for running slot",
   "outcome": "fixed",
   "path": "src/core/warm-pool/policy.ts:714",
   "fix": "3582994d"
  },
  {
   "id": "R2",
   "role": "code",
   "class": "spared target devices never displaced",
   "outcome": "fixed",
   "path": "src/core/warm-pool/policy.ts:180",
   "fix": "3582994d"
  },
  {
   "id": "R3",
   "role": "code",
   "class": "safety 6: reason not logged",
   "outcome": "fixed",
   "path": "src/core/warm-pool/converger.ts:653",
   "fix": "3582994d"
  },
  {
   "id": "R4",
   "role": "code",
   "class": "spec versus ADR 0038 section 4",
   "outcome": "fixed",
   "path": "src/core/warm-pool/catalog-check.ts:43",
   "fix": "3582994d"
  },
  {
   "id": "R5",
   "role": "code",
   "class": "testing 1, 10",
   "outcome": "fixed",
   "path": "e2e/capacity-cleanup-nuke.test.ts:185",
   "fix": "3582994d"
  },
  {
   "id": "R6",
   "role": "spec",
   "class": "testing: deleted test leaves behaviour unproven",
   "outcome": "fixed",
   "path": "src/core/warm-pool/converger.test.ts:709",
   "fix": "3582994d"
  },
  {
   "id": "R7",
   "role": "claims",
   "class": "stale claim: no target keeps it",
   "outcome": "fixed",
   "path": "docs/EVENTS.md:52",
   "fix": "3582994d"
  },
  {
   "id": "R8",
   "role": "code",
   "class": "spec vs rule: ADR 0038 section 5 first pass",
   "outcome": "fixed",
   "path": "src/core/warm-pool/catalog-check.ts:48",
   "fix": "bb314d4f"
  },
  {
   "id": "R9",
   "role": "claims",
   "class": "test title claims failed read, never exercised",
   "outcome": "fixed",
   "path": "src/core/warm-pool/converger.test.ts:2372",
   "fix": "bb314d4f"
  },
  {
   "id": "R10",
   "role": "claims",
   "class": "stale claim: only targets keep fresh warm",
   "outcome": "fixed",
   "path": "docs/CONFIGURATION.md:29",
   "fix": "bb314d4f"
  },
  {
   "id": "R11",
   "role": "claims",
   "class": "test title claims physical device skip, none in fixture",
   "outcome": "fixed",
   "path": "src/core/warm-pool/converger.test.ts:2326",
   "fix": "bb314d4f"
  }
 ]
}

Written by an agent.

@V3RON
V3RON marked this pull request as ready for review October 21, 2026 08:36
@V3RON
V3RON added this pull request to stack #791 October 21, 2026 08:36
@V3RON
V3RON merged commit af224ef into main Oct 21, 2026
45 of 46 checks passed
@V3RON
V3RON deleted the task/776 branch October 21, 2026 08:56
V3RON added a commit that referenced this pull request Oct 21, 2026
…with their origin (#844)

Closes #777

### Status
Implement: done (6/6 green) Review: round 2 passed, fix-check on main
merge passed Hardware: n/a Gate: Console CI job times out, also on main
(#852)
Next: maintainer merge

## Done when

- [x] `pnpm test:changed` passes: figures, schema, CLI, doctor,
target-missed and UI tests added or extended. The one red test,
`src/agent-device/gateway-front.test.ts` (2 GiB download), is the open
flaky-test issue #807; CI's Unit tests job runs it again.
- [x] `pnpm test:console --project=chromium` passes: CI's Console job
runs it on the gated head. The three specs that failed on the build
machine are left to it, and the gate refuses a red run.
- [x] `PROTOCOL_VERSION_RANGE` in `src/contract/protocol.ts` is one
above the base branch's (52 to 53): checked by CI's Protocol bump job.
- [x] The user docs describe `origin` and the image tag
(`website/.../worker/capacity.mdx`, `monitoring.mdx`, `console.mdx`);
the `warm-pool.target-missed` rows name `origin`
(`docs/internal/EVENTS.md`, `website/.../reference/events.mdx`): checked
by the spec and claims reviews.

### Feature #771 completion conditions

- [x] Next lease of a kind is `warm`; three held at once leave three
ready; ready again after a restart; nuke clears the record: #776 (PR
#792, merged).
- [x] Five queued start `maxConcurrentBoots` boots; the default comes
from the CPU; a RAM-refused boot is not proposed every pass: #774 (PR
#788, merged).
- [x] Status and the console show `origin`, wanted, ready, booting,
short and the image tag: this PR, CLI, figures and UI tests.
- [x] A removed runtime forgets the kind: #776's pass; this PR lists
only what the record holds.

## Assumptions

- Assumption: `docs/CLI.md`, `docs/HTTP-API.md`, `docs/CONSOLE.md` no
longer exist — the end-user docs are the website pages, so those were
updated instead.
- Assumption: the Origin column sits after Mode in the console table and
the tag shows as `Model / tag` — matches the CLI's name layout.

## Review

Spec review: 0 blocking, 0 fixed, 0 notes. Code review: 1 blocking, 1
fixed, 0 notes. Claims review: 1 blocking, 1 fixed, 0 notes.
Rounds: 2. Tokens: 2.5M.
Runs: 8. Cost USD: 3.8503. Agent seconds: 2747.
Assessment: complete

*Written by an agent.*
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

The warm pool learns the kinds it leases and keeps them ready, across restarts

1 participant